package com.appwoo.txtws.util;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;
import com.appwoo.txtws.activity.MainActivity;
import com.appwoo.txtws.bean.AutoSoftInfo;
import com.appwoo.txtws.component.DBHelper;
import java.io.PrintStream;
import java.util.ArrayList;

public class DateAdapter extends BaseAdapter
{
  private Context context;
  private DBHelper dbHelper;
  private int gridViewItemHeight;
  int i;
  private ArrayList<AutoSoftInfo> lstDate;
  private PackageManager pm;
  private Resources res;

  public DateAdapter(Context paramContext, ArrayList<AutoSoftInfo> paramArrayList, int paramInt1, DBHelper paramDBHelper, int paramInt2)
  {
    this.context = paramContext;
    this.res = this.context.getResources();
    this.lstDate = paramArrayList;
    this.i = paramInt1;
    this.pm = this.context.getPackageManager();
    this.dbHelper = paramDBHelper;
    this.gridViewItemHeight = paramInt2;
  }

  private void changeParentid(int paramInt, ArrayList<ShortcutInfo> paramArrayList)
  {
    int j = 0;
    if (j >= paramArrayList.size())
      return;
    label83: for (int k = 0; ; k++)
    {
      if (k >= this.lstDate.size());
      while (true)
      {
        j++;
        break;
        if (!((ShortcutInfo)paramArrayList.get(j)).getPackageName().equals(((AutoSoftInfo)this.lstDate.get(k)).getAspkg()))
          break label83;
        ((AutoSoftInfo)this.lstDate.get(k)).setAsParentid(paramInt);
      }
    }
  }

  public void exchange(int paramInt1, int paramInt2)
  {
    AutoSoftInfo localAutoSoftInfo1;
    AutoSoftInfo localAutoSoftInfo2;
    if (paramInt1 != paramInt2)
    {
      localAutoSoftInfo1 = (AutoSoftInfo)getItem(paramInt2);
      localAutoSoftInfo2 = (AutoSoftInfo)getItem(paramInt1);
      if ((localAutoSoftInfo1.getAsIsFolder() != 0) || (localAutoSoftInfo1.getAsParentid() != 0) || (localAutoSoftInfo2.getAsIsFolder() != 0))
        break label86;
      localAutoSoftInfo2.setAsParentid(localAutoSoftInfo1.getAsid());
      localAutoSoftInfo1.setAsParentid(localAutoSoftInfo1.getAsid());
      localAutoSoftInfo1.setAsIsFolder(1);
      localAutoSoftInfo1.setAsFolderName("文件夹");
      this.dbHelper.changeToFolder(localAutoSoftInfo1, localAutoSoftInfo2);
    }
    label86: 
    do
    {
      return;
      if ((localAutoSoftInfo1.getAsIsFolder() == 1) && (localAutoSoftInfo2.getAsIsFolder() == 0))
      {
        localAutoSoftInfo2.setAsParentid(localAutoSoftInfo1.getAsid());
        this.lstDate.add(paramInt1, localAutoSoftInfo2);
        this.lstDate.remove(paramInt1 + 1);
        this.dbHelper.updateParentid(localAutoSoftInfo2.getAsid(), localAutoSoftInfo2.getAsParentid());
        return;
      }
    }
    while (((localAutoSoftInfo1.getAsIsFolder() == 0) && (localAutoSoftInfo1.getAsParentid() != 0) && (localAutoSoftInfo2.getAsIsFolder() == 0)) || (localAutoSoftInfo2.getAsIsFolder() != 1) || (localAutoSoftInfo1.getAsIsFolder() != 0));
    int j = localAutoSoftInfo2.getAsid();
    if (localAutoSoftInfo1.getAsParentid() == localAutoSoftInfo2.getAsid())
      localAutoSoftInfo1.setAsParentid(localAutoSoftInfo1.getAsid());
    localAutoSoftInfo2.setAsid(localAutoSoftInfo1.getAsid());
    localAutoSoftInfo2.setAsParentid(localAutoSoftInfo1.getAsid());
    changeParentid(localAutoSoftInfo2.getAsParentid(), localAutoSoftInfo2.getContents());
    localAutoSoftInfo1.setAsid(j);
    this.lstDate.add(paramInt1, localAutoSoftInfo1);
    this.lstDate.remove(paramInt1 + 1);
    this.lstDate.add(paramInt2, localAutoSoftInfo2);
    this.lstDate.remove(paramInt2 + 1);
    this.dbHelper.changeOrder(localAutoSoftInfo2, localAutoSoftInfo1);
  }

  public int getCount()
  {
    return this.lstDate.size();
  }

  public Object getItem(int paramInt)
  {
    return this.lstDate.get(paramInt);
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    View localView = LayoutInflater.from(this.context).inflate(2130903107, null);
    localView.setLayoutParams(new AbsListView.LayoutParams(-1, this.gridViewItemHeight));
    AutoSoftInfo localAutoSoftInfo = (AutoSoftInfo)this.lstDate.get(paramInt);
    ImageView localImageView1 = (ImageView)localView.findViewById(2131493119);
    TextView localTextView1 = (TextView)localView.findViewById(2131493122);
    if ((paramInt == 0) && (this.i == 0))
    {
      if (MainActivity.intMarketRecdCount > 0)
      {
        TextView localTextView2 = (TextView)localView.findViewById(2131493121);
        localTextView2.setVisibility(0);
        localTextView2.setText(MainActivity.intMarketRecdCount);
      }
      localImageView1.setImageDrawable(this.res.getDrawable(2130838135));
      localTextView1.setText(localAutoSoftInfo.getAsname());
      return localView;
    }
    if ((paramInt == 1) && (this.i == 0))
    {
      localImageView1.setImageDrawable(this.res.getDrawable(2130838047));
      localTextView1.setText(localAutoSoftInfo.getAsname());
      return localView;
    }
    if ((paramInt == 2) && (this.i == 0))
    {
      localImageView1.setImageDrawable(this.res.getDrawable(2130838053));
      localTextView1.setText(localAutoSoftInfo.getAsname());
      return localView;
    }
    if ((paramInt == 3) && (this.i == 0))
    {
      localImageView1.setImageDrawable(this.res.getDrawable(2130838082));
      localTextView1.setText(localAutoSoftInfo.getAsname());
      return localView;
    }
    if ((paramInt == 4) && (this.i == 0))
    {
      localImageView1.setImageDrawable(this.res.getDrawable(2130838043));
      localTextView1.setText(localAutoSoftInfo.getAsFolderName());
      return localView;
    }
    if ((paramInt == 5) && (this.i == 0))
    {
      localImageView1.setImageDrawable(this.res.getDrawable(2130838069));
      localTextView1.setText(localAutoSoftInfo.getAsFolderName());
      return localView;
    }
    if ((paramInt == 6) && (this.i == 0))
    {
      localImageView1.setImageDrawable(this.res.getDrawable(2130838081));
      localTextView1.setText(localAutoSoftInfo.getAsFolderName());
      return localView;
    }
    if ((paramInt == 7) && (this.i == 0))
    {
      localImageView1.setImageDrawable(this.res.getDrawable(2130838048));
      localTextView1.setText(localAutoSoftInfo.getAsFolderName());
      return localView;
    }
    if (localAutoSoftInfo.getAsIsFolder() == 1)
    {
      localImageView1.setScaleType(ImageView.ScaleType.FIT_XY);
      if (localAutoSoftInfo.getDeskicon() != null)
        localImageView1.setImageDrawable(localAutoSoftInfo.getDeskicon());
      while (true)
      {
        localTextView1.setText(localAutoSoftInfo.getAsFolderName());
        return localView;
        localImageView1.setImageDrawable(this.res.getDrawable(2130837701));
      }
    }
    if (localAutoSoftInfo.getAsIsNew() == 1)
    {
      ImageView localImageView2 = (ImageView)localView.findViewById(2131493120);
      localImageView2.setVisibility(0);
      localImageView2.setBackgroundResource(2130837829);
    }
    while (true)
    {
      try
      {
        this.pm.getApplicationInfo(localAutoSoftInfo.getAspkg(), 8192);
        if ("com.huawei.android.ChinaTelecomCustomize".equals(((AutoSoftInfo)this.lstDate.get(paramInt)).getAspkg()))
        {
          localImageView1.setImageDrawable(this.context.getResources().getDrawable(2130838080));
          System.out.println("getApplicationLabel  name1-----" + this.pm.getActivityInfo(new ComponentName(localAutoSoftInfo.getAspkg(), localAutoSoftInfo.getActivityName()), -1).loadLabel(this.pm));
          localTextView1.setText(this.pm.getActivityInfo(new ComponentName(localAutoSoftInfo.getAspkg(), localAutoSoftInfo.getActivityName()), -1).loadLabel(this.pm));
          return localView;
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return localView;
      }
      localImageView1.setImageDrawable(this.pm.getActivityIcon(new ComponentName(localAutoSoftInfo.getAspkg(), localAutoSoftInfo.getActivityName())));
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.util.DateAdapter
 * JD-Core Version:    0.6.2
 */